package org.fastsyncer.common.constant;

import java.util.HashMap;

/**
 * <p>目前支持：</p>
 * <ul>
 * <li>Mysql连接器</li>
 * <li>Oracle连接器</li>
 * <li>SqlServer连接器</li>
 * <li>SqlMysql连接器</li>
 * <li>SqlOracle连接器</li>
 * <li>Ladp连接器</li>
 * <li>Redis连接器</li>
 * <li>Webservice连接器</li>
 * </ul>
 * @ClassName: ConnectorConstant 
 * @Description: 连接器类型常量类型
 * @author AE86
 * @date: 2017年8月11日 上午11:05:39
 */
public class ConnectorConstant {

    /**
     * Mysql连接器
     */
    public static final String MYSQL_CONNECTOR = "org.fastsyncer.connector.mysql.MysqlConnector";
    
    /**
     * Oracle连接器
     */
    public static final String ORACLE_CONNECTOR = "org.fastsyncer.connector.oracle.OracleConnector";
	
    /**
     * Sql_Mysql连接器
     */
    public static final String SQL_MYSQL_CONNECTOR = "org.fastsyncer.connector.sql.SqlMysqlConnector";
    
    /**
     * Sql_Oracle连接器
     */
    public static final String SQL_ORACLE_CONNECTOR = "org.fastsyncer.connector.sql.SqlOracleConnector";

    /**
     * SqlServer连接器
     */
    public static final String SQLSERVER_CONNECTOR = "org.fastsyncer.connector.sqlserver.SqlServerConnector";
    
	/**
	 * Webservice连接器
	 */
	public static final String WS_CONNECTOR = "org.fastsyncer.connector.ws.WebServiceConnector";

	/**
	 * Ladp连接器
	 */
	public static final String LDAP_CONNECTOR = "org.fastsyncer.connector.ldap.LdapConnector";
	
    /**
     * Redis连接器
     */
    public static final String REDIS_CONNECTOR = "org.fastsyncer.connector.redis.RedisConnector";
	
	/**
	 * 新增
	 */
	public static final String OPERTION_INSERT = "INSERT";

	/**
	 * 更新
	 */
	public static final String OPERTION_UPDATE = "UPDATE";

	/**
	 * 删除
	 */
	public static final String OPERTION_DELETE = "DELETE";

	/**
	 * 查询
	 */
	public static final String OPERTION_QUERY = "QUERY";

    /**
     * 日志_增量查询
     * <p>例如：WHERE USER.ID = ?</p>
     */
    public static final String OPERTION_QUERY_LOG = "QUERY_LOG";
    
    /**
     * 定时器_增量查询
     * <p>例如：SELECT ASD_TEST.* FROM ASD_TEST</p>
     */
    public static final String OPERTION_QUERY_QUARTZ = "QUERY_QUARTZ";
    
    /**
     * 定时器_增量查询条件:增量字段 < 增量时间 <= 增量字段
     * <p>T1.LASTDATE > '2017-11-10 11:07:41' AND T1.LASTDATE <= '2017-11-10 11:30:01' ORDER BY LASTDATE</p>
     */
    public static final String OPERTION_QUERY_QUARTZ_RANGE = "QUERY_QUARTZ_RANGE";
    
    /**
     * 定时器_增量查询条件:增量字段<= 增量时间
     * <p>T1.LASTDATE <= '2017-11-10 11:07:41' ORDER BY T1.LASTDATE</p>
     */
    public static final String OPERTION_QUERY_QUARTZ_ALL = "QUERY_QUARTZ_ALL";
    
    /**
     * 定时器_增量查询最后记录点 
     * <p>例如：SELECT MAX(T1.LASTDATE) FROM ASD_TEST T1</p>
     */
    public static final String OPERTION_QUERY_QUARTZ_MAX = "QUERY_QUARTZ_MAX";
	
	/**
	 * 条件查询and
	 */
	public static final String OPERTION_QUERY_AND = "and";
	
	/**
	 * 条件查询or
	 */
	public static final String OPERTION_QUERY_OR = "or";
	
	/**
	 * 查询表达式
	 */
	public static final HashMap<String, String> OPERS = new HashMap<String, String>();
	
	static {
		OPERS.put("equal", "=");
		OPERS.put("notEqual", "!=");
		OPERS.put("gt", ">");
		OPERS.put("lt", "<");
		OPERS.put("gtAndEqual", ">=");
		OPERS.put("ltAndEqual", "<=");
	}
	
	/**
	 * 检查是否为关系型数据库类型
	 * @param connector 连接器名称
	 * @return true/false
	 */
	public static boolean isDatabaseConnector(String connector){
	    return MYSQL_CONNECTOR.equals(connector) || ORACLE_CONNECTOR.equals(connector) || SQL_MYSQL_CONNECTOR.equals(connector) || SQL_ORACLE_CONNECTOR.equals(connector) || SQLSERVER_CONNECTOR.equals(connector);
	}
	
}
